package com.jiang.jixiang.ui.adapter;

import android.annotation.SuppressLint;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.jiang.jixiang.R;
import com.jiang.jixiang.bean.OrderListBean;
import com.jiang.jixiang.tools.PriceUtils;
import com.ws.universal.tools.utils.StringUtils;

public class OrderAdapter extends BaseQuickAdapter<OrderListBean.OrderList, BaseViewHolder> {
    //private int type;//1租借 2购买，

    public OrderAdapter() {
        super(R.layout.item_myorder);

    }

    @SuppressLint("ResourceAsColor")
    @Override
    protected void convert(@NonNull BaseViewHolder holder, OrderListBean.OrderList bean) {
        TextView tvItemAmount = holder.findView(R.id.tvItemAmount);
        TextView tvItemStatus = holder.findView(R.id.tvItemStatus);
        TextView tvItemRentalLocation = holder.findView(R.id.tvItemRentalLocation);
        TextView tvItemTime = holder.findView(R.id.tvItemTime);
        ImageView imgItemStatus = holder.findView(R.id.imgItemStatus);
        holder.setText(R.id.tvItemNumber, StringUtils.getString(getContext().getString(R.string.order_no), bean.getOrder_no()));

        if (bean.getStatus() == 1) { //进行中
            tvItemAmount.setTextColor(getContext().getColor(R.color.main_color));
            tvItemStatus.setTextColor(getContext().getColor(R.color.main_color));
            tvItemRentalLocation.setTextColor(getContext().getColor(R.color.main_color));
            tvItemTime.setTextColor(getContext().getColor(R.color.main_color));
            tvItemStatus.setText(getContext().getString(R.string.charging));
            imgItemStatus.setImageResource(R.mipmap.icon_item_ordered);
        } else {
            tvItemAmount.setTextColor(getContext().getColor(R.color.text_minor_color));
            tvItemStatus.setTextColor(getContext().getColor(R.color.text_minor_color));
            tvItemRentalLocation.setTextColor(getContext().getColor(R.color.text_minor_color));
            tvItemTime.setTextColor(getContext().getColor(R.color.text_minor_color));
            tvItemStatus.setText(getContext().getString(R.string.completed));
            imgItemStatus.setImageResource(R.mipmap.icon_item_order);

        }
        tvItemAmount.setText(StringUtils.getString(getContext().getString(R.string.money), PriceUtils.getPrice(bean.getAmount())));
        holder.setText(R.id.tvItemRentalLocation, StringUtils.getString(bean.getLease_address()));
        holder.setText(R.id.tvItemTime, StringUtils.getString(bean.getStart_time()));
        //holder.setText(R.id.tvItemUsageTime, StringUtils.getString(bean.getUse_time()));


    }
}
